package com.web.servlet;

import com.web.entity.Teacher;
import com.web.service.TeacherService;
import com.web.serviceimpl.TeacherServiceImpl;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
* 教师修改密码
*
* @author 12270
*/
@WebServlet("/mtps")
public class ModifyTeacherPwdServlet extends HttpServlet {
    
    TeacherService teacherService = new TeacherServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        //获取老师修改后密码的信息，封装成一个老师对象
        req.setCharacterEncoding("utf-8");
        String Tid = req.getParameter("Tid");
        String Tpwd = req.getParameter("Tpwd");
        
        
        //获取老师密码信息，封装成一个teacher对象
        Teacher teacher = new Teacher(Tid,Tpwd);
        
        int rows = teacherService.modifyTeacherTpwd(teacher);
        //生成响应内容，这里返回受影响的行数用于判断是否修改成功
        resp.getWriter().print(rows);
        PrintWriter out=resp.getWriter();
        System.out.println(rows);
    }
}
    

